﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;

namespace WebApp3
{
    public partial class frmUserXgmm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] == null)
            {
                Page.Theme = "浅蓝色";
            }
            else if (Session["Theme"] == "浅蓝色")
            {
                Page.Theme = "浅蓝色";
            }
            else if (Session["Theme"] == "绿色")
            {
                Page.Theme = "绿色";
            }
            else if (Session["Theme"] == "黄色")
            {
                Page.Theme = "黄色";
            }
            else
            {
                Page.Theme = "红色";
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112111;uid=2014112111;pwd=19950511";
            SqlConnection cn = new SqlConnection(strCn);
            string chuandiname;
            chuandiname = Session["chuandiname"].ToString();
            try
            {
                cn.Open();
                string chuandipassword;
                chuandipassword = Session["chuandipassword"].ToString();
                if (this.txtOlder.Text == chuandipassword)
                {
                    string strHelp = "UPDATE  UserInfo  SET         Password = N'" + txtPassword.Text + "'   WHERE   (UserName = N'" + chuandiname + "')";
                    SqlCommand cnd = new SqlCommand(strHelp, cn);
                    int iUpd = cnd.ExecuteNonQuery();
                    if (iUpd < 1)
                    {
                        this.lblOk.Text = "修改失败！";
                    }
                    this.lblOk.Text = "密码已修改，请记住新密码！";
                }

                else
                {
                    this.lblOk.Text = "原密码输入错误，请重新输入！";

                }

            }
            catch (Exception ex)
            {

                this.lblOk.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }
    }
}